import Ember from 'ember';
import ListItem from '../../ui/mobile/list-item';
import BaseUiItem from '../../ui/base-ui-item';

export default BaseUiItem.extend(ListItem,{
  store: Ember.inject.service("store"),
  feedBus: Ember.inject.service("feed-bus"),
  classStatic: true,
  classNameBindings: ['classStatic:line-item-task','isExpand:expand','outerClass'],
  outerClass:"",
  /*标记*/
  name: "listTaskItem",
  itemId: null,
  dataType: "task",//数据模式，user：按用户显示 task：按任务显示
  /*控制相关属性*/
  recognizers:"tap pan",
  showMode: "normal",//显示模式 正常：normal 展开：expand 显示功能按钮：showFunc
  /*显示相关属性*/
  icon:null,
  content:null,
  title:null,
  label:null,

  isExpand:Ember.computed("showMode",function(){
    if(this.get("showMode")==="expand"){
      return true;
    }
    return false;
  }),
  didInsertElement: function(){
    if(this.get("item.hasApply")){
      this.set("disabled",true);
    }
    this._super();
  },
  actions:{
    tapAct(event){
      this.send("gotoDetail");
    },
    panMoveProcAction(e){
      //移除本级并显示提示
      // this.sendAction("panMoveProcAction",this.get("itemId"));
      //切换成按钮显示方式
      this.set("showMode","showFunc");
      //完整显示按钮
      // this.$().css('margin-right',0);
    },
    expandDetail(){
      this.set("showMode","expand");
    },
    hideDetail(){
      this.set("showMode","normal");
    },
    gotoDetail(){
      console.log("go task detail");
      var mainpageController = App.lookup('controller:business.mainpage');
      //通过全局服务进行上下文传值
      this.get("feedBus").set("threadData",this.get("item"));
      mainpageController.switchMainPage('task-detail',{taskId:this.get("item.id")});
    },
    finish(){
      console.log("finish in",this.get("item"));
      //复位
      this.reset();
      this.sendAction("finish",this.get("item"));
    }
  }

});
